package com.itlong.cloud.app.resource;

import com.itlong.cloud.POJO.DTO.app.AppGetDateListPageDTO;
import com.itlong.cloud.POJO.DTO.app.AppGetPassRecordListPageDTO;
import com.itlong.cloud.POJO.VO.app.AppGetPassRecordListPageVO;
import com.itlong.cloud.POJO.VO.app.AppUploadPassErrorVO;
import com.itlong.cloud.app.service.IAppDevicePassRecordService;
import com.itlong.cloud.equip.app.IAppDevicePassRecordServiceClient;
import com.itlong.cloud.utils.page.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * <desc>
 *      用户通行记录业务处理暴露接口
 * </desc>
 *
 * @createDate 2017/11/09
 */
@RestController
public class AppDevicePassRecordServiceResource implements IAppDevicePassRecordServiceClient{
    @Autowired
    private IAppDevicePassRecordService iAppDevicePassRecordService;

    /**
     * <desc>
     *      获取用户有通行记录的日期分页列表
     * </desc>
     *
     * @param dto dto参数实体
     * @return
     * @author Jiaqi.X
     * @createDate 2017/11/09
     */
    @Override
    @RequestMapping(value = "/app/devicePassRecord/getDoorDevices",method = RequestMethod.POST)
    public Page<String> getPassDateListPage(@RequestBody AppGetDateListPageDTO dto) throws Exception{
        return iAppDevicePassRecordService.getPassDateListPage(dto);
    }

    /**
     * <desc>
     *      获取用户通行记录分页列表
     * </desc>
     *
     * @param dto 参数dto类
     * @return
     * @throws Exception
     * @author Jiaqi.X
     * @createDate 2017/11/09
     */
    @Override
    @RequestMapping(value = "/app/devicePassRecord/getPage",method = RequestMethod.POST)
    public Page<AppGetPassRecordListPageVO> getPage(@RequestBody AppGetPassRecordListPageDTO dto) throws Exception {
        return iAppDevicePassRecordService.getPage(dto);
    }

    /**
     * <desc>
     *      上传用户通行记录
     * </desc>
     *
     * @param userId   用户id
     * @param recordJson json数据串
     * @return
     * @author Jiaqi.X
     * @createDate 2017/11/10
     */
    @Override
    @RequestMapping(value = "/app/devicePassRecord/uploadRecord",method = RequestMethod.POST)
    public List<AppUploadPassErrorVO> uploadRecord(@RequestParam("userId") String userId,
                                            @RequestParam("projectId") String projectId,
                                            @RequestParam("recordJson") String recordJson,
                                            @RequestParam("imageStr") String imageStr,
                                            @RequestParam("imageType") String imageType) throws Exception{
        return iAppDevicePassRecordService.uploadRecord(userId,projectId,recordJson,imageStr,imageType);
    }


    /**
     * <desc>
     *       同步通行记录至具体设备通行记录表
     * </desc>
     *
     * @author Jiaqi.X
     * @createDate 2017/11/10
     */
    @Override
    @RequestMapping(value = "/app/devicePassRecord/timeTaskSychro",method = RequestMethod.POST)
    public void timeTaskSychro() throws Exception {
        iAppDevicePassRecordService.timeTaskSychro();
    }

    /**
     * <desc>
     *      以用户为基准删除通行时间大于3个月的记录
     * </desc>
     *
     * @author Jiaqi.X
     * @createDate 2017/11/13
     */
    @Override
    @RequestMapping(value = "/app/devicePassRecord/timeTaskDeleteRecord",method = RequestMethod.POST)
    public void timeTaskDeleteRecord() {
        iAppDevicePassRecordService.timeTaskDeleteRecord();
    }

    /**
     * <desc>
     *      获取通行记录列表，app2.0版本新增
     * </desc>
     *
     * @param projectId 项目编号
     * @param pageIndex 当前页数(每页15条)
     * @param userId 用户id
     * @return 通行记录列表
     * @author wangzhi
     * @createDate 2019/06/18
     */
    @Override
    @RequestMapping(value = "/app/devicePassRecord/getOpenDoorRecord",method = RequestMethod.POST)
    public Map<String, Object> getOpenDoorRecord(@RequestParam("projectId") String projectId, @RequestParam("pageIndex") String pageIndex, @RequestParam("userId") String userId) throws Exception {
        return iAppDevicePassRecordService.getOpenDoorRecord(projectId, pageIndex, userId);
    }

    /**
     * <desc>
     *      获取电梯通行记录列表，app2.0版本新增
     * </desc>
     *
     * @param pageNum 当前页数(每页15条)
     * @param userId 用户id
     * @return 通行记录列表
     * @author Qiang.S
     * @createDate 2019/06/26
     */
    @Override
    @RequestMapping(value = "/app/devicePassRecord/getLiftHistory",method = RequestMethod.POST)
    public Map<String, Object> getLiftHistory(@RequestParam("pageNum") String pageNum, @RequestParam("userId") String userId) throws Exception {
        return iAppDevicePassRecordService.getLiftHistory(pageNum, userId);
    }

    /**
     * <desc>
     *      获取访客通行密码邀请记录
     * </desc>
     *
     * @param projectId 项目编号
     * @param pageNo 页数
     * @param pageSize 每页数
     * @param userId 用户id
     * @return 访客通行密码邀请记录
     * @author wangzhi
     * @createDate 2019/06/24
     */
    @Override
    @RequestMapping(value = "/app/devicePassRecord/getInviteRecord",method = RequestMethod.POST)
    public Map<String, Object> getInviteRecord(@RequestParam("projectId") String projectId, @RequestParam("pageNo") String pageNo,
                                               @RequestParam("pageSize") String pageSize, @RequestParam("userId") String userId) throws Exception {
        return iAppDevicePassRecordService.getInviteRecord(projectId, pageNo, pageSize, userId);
    }

    /**
     * <desc>
     * 访客详情
     * </desc>
     *
     * @param passId@return
     * @author caoshuai
     * @createDate 2021/1/21 15:47
     */
    @Override
    @RequestMapping(value = "/app/devicePassRecord/getVisitorsInfo",method = RequestMethod.POST)
    public Map<String, Object> getVisitorsInfo(@RequestParam("passId") String passId) {
        return iAppDevicePassRecordService.getVisitorsInfo(passId);
    }
}

